#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int n, i, j, profit = -1000, max = -1000;
  int arr[10001];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &arr[i]);
  }

  for (i = 0; i < n - 1; i++)
  {
    for (j = i + 1; j < n; j++)
    {
      if (profit < (arr[j] - arr[i])) // arr[j] - arr[i]当前利润
      {
        profit = arr[j] - arr[i];
        
      }
    }
    if (max < profit)
    {
      max = profit;
    }
  }
  printf("%d", max);
  return 0;
}
